/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 * \file
 * \brief Protocol encoder/decoder header for the Parameter protocol.
 * \author Matthieu Myrsky <matthieu.myrsky@tkk.fi>
 *
 * $Id: ParameterData.hpp,v 1.2 2009-12-08 10:48:28 morsko Exp $
 * 
 */
#ifndef _MACI_PARAMETERDATA_HPP_
#define _MACI_PARAMETERDATA_HPP_
#include "ParameterXML.hpp"
#include "ParameterTypes.hpp"
#include "MaCIData.hpp"
#include "common/timestamp.hpp"
#include "common/text.hpp"
#include <vector>



namespace gim {
  namespace binbag{class CBinBag;}
}

namespace MaCI {
  namespace Parameter {
    /** Parameter protocol parser.
     *
     * This class contains the methods for decoding/encoding a 
     * Parameter message.
     */
    class CParameterData : public CMaCIData
    {
    public:
      CParameterData();
      ~CParameterData();

      // Copy constructor.
      CParameterData(const CParameterData &);

      // Assignment operator.
      CParameterData &operator=(const CParameterData &);

      // Interface for moving data around
      bool DecodeFrom(gim::binbag::CBinBag *aBinBag);
      void Reset();
      void Print(const int level) const;


      /** Set timestamp element.
       * 
       */
      bool SetTimestamp(const Common::TTimestamp &aStamp);


      /** Set command element.
       * This function stores a element of type TCommand.
       *
       * @return                'true' if element was succesfully added,
       *                        'false' if element already exists.
       */
      bool SetCommand(const TCommand &aCmd);

      /** Set TParameterXML element.
       *
       * This function stores a element of type TParameterXML.
       *
       * @return                'true' if element was succesfully added,
       *                        'false' if element already exists.
       */
      bool SetParameterXML(const TParameterXML &aXML);

      /** Set ParameterXML by creating one from a std::string.
       *
       * @param[in] aXMLString   String to encode as ParameterXML.
       * @return                'true' if element was succesfully added,
       *                        'false' if element already exists.
       */
      bool SetParameterXMLString(const std::string &aXMLString);
      

      /** Get pointer to TTimestamp element.
       * 
       * @return                 Pointer to element if such exists, 
       *                         NULL if element doesn't exists in the
       *                         container.
       */
      const MaCI::Common::TTimestamp *GetTimestamp(void) const;
      

      /** Get pointer to TCommand element.
       *
       * @return                 Pointer to element if such exists, 
       *                         NULL if element doesn't exists in the
       *                         container.
       */
      const TCommand *GetCommand(void) const;

      /** Get pointer to TParameterXML element.
       *
       * @return                 Pointer to element if such exists, 
       *                         NULL if element doesn't exists in the
       *                         container.
       */
      const TParameterXML *GetParameterXML(void) const;

    private:
      const Common::TTimestamp *iTimestampPtr; ///< Pointer to timestamp.
      const TCommand *iCommandPtr; ///< Pointer to command.
      const TParameterXML *iParameterXMLPtr; ///< Pointer to Parameter XML.
    };

  }

}
#endif
